package cn.uppower.wordaliy.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import cn.uppower.wordaliy.R;
import cn.uppower.wordaliy.widget.WordaliyCalendar;

/**
 * Created by elitetyc on 2018/11/26.
 * Describe:
 */
public class DakaFragment extends Fragment {

    private WordaliyCalendar calendar_daka;
    private TextView tv_lxqd,tv_ljqd;
    private Button btn_punch;


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=View.inflate(getActivity(), R.layout.fragment_daka,null);
        calendar_daka = view.findViewById(R.id.calendar_daka);
        tv_ljqd = view.findViewById(R.id.tv_ljqd);
        tv_lxqd = view.findViewById(R.id.tv_lxqd);
        btn_punch = view.findViewById(R.id.btn_punch);
        updateDays();
        btn_punch.setOnClickListener((e)->{
            calendar_daka.setLjqd(calendar_daka.getLjqd()+1);
            calendar_daka.setLxqd(calendar_daka.getLxqd()+1);
            updateDays();
            btn_punch.setEnabled(false);
            btn_punch.setText("今日已签到");

        });

        return view;
    }

    private void updateDays(){
        tv_ljqd.setText(String.valueOf(calendar_daka.getLjqd()));
        tv_lxqd.setText(String.valueOf(calendar_daka.getLxqd()));
    }


}
